#include "section_define.h"
#include "section3_change_func.h"
#include "main.h"

#ifdef PBS_FILTER
extern unsigned char g_uNo3RegList[64];
extern int My_Memcmp(unsigned char *data1,unsigned char *data2,unsigned short len);
#endif


unsigned char on_section3_change(unsigned short addr, unsigned char* regdata)
{
	unsigned char regdata_len = 0xff;
//	Log_Printf("addr = 0x%04X\r\n",addr);
	InDoorBusReg Reg = {0};
	Reg.V8 = regdata[0];
	switch(addr)
	{
		case SECTION3_ADDR_H200:
#ifdef PBS_FILTER
			if(My_Memcmp(regdata,&g_uNo3RegList[addr-0x200],1)) return 1;
#endif			
		
			regdata_len = 1;
		break;             
		case SECTION3_ADDR_H201:	
			
			addr -=  0x200;
			
			if(Reg.V8 == g_uNo3RegList[addr]) return 1;
		
			A201_12_12_StatusChange(Reg.V8,g_uNo3RegList[addr]);
		
			g_uNo3RegList[addr] = Reg.V8;					
				
			regdata_len = 1;
		
		break;             
		case SECTION3_ADDR_H202:
#ifdef PBS_FILTER
			if(My_Memcmp(regdata,&g_uNo3RegList[addr-0x200],2)) return 2;
#endif					
			A202_12_7_StatusChange((regdata[1]<<8)|regdata[0]);
			regdata_len = 2;
		
		break;             
		            
		case SECTION3_ADDR_H204:
#ifdef PBS_FILTER
			if(My_Memcmp(regdata,&g_uNo3RegList[addr-0x200],2)) return 2;
#endif					
			A204_12_9_StatusChange((regdata[1]<<8)|regdata[0]);
			regdata_len = 2;
		
		break;             
		           
		case SECTION3_ADDR_H206:
#ifdef PBS_FILTER
			if(My_Memcmp(regdata,&g_uNo3RegList[addr-0x200],2)) return 2;
#endif					
			A206_255_48_StatusChange((regdata[1]<<8)|regdata[0]);
			regdata_len = 2;
		
		break;             
		           
		case SECTION3_ADDR_H208:
#ifdef PBS_FILTER
			if(My_Memcmp(regdata,&g_uNo3RegList[addr-0x200],2)) return 2;
#endif					
			A208_12_25_StatusChange((regdata[1]<<8)|regdata[0]);
			regdata_len = 2;
		
		break;             
		            
		case SECTION3_ADDR_H20A:
#ifdef PBS_FILTER
			if(My_Memcmp(regdata,&g_uNo3RegList[addr-0x200],2)) return 2;
#endif					
			A20A_12_31_StatusChange((regdata[1]<<8)|regdata[0]);
			regdata_len = 2;
		
		break;             
		            
		case SECTION3_ADDR_H20C:
#ifdef PBS_FILTER
			if(My_Memcmp(regdata,&g_uNo3RegList[addr-0x200],2)) return 12;
#endif					
			A20C_12_8_StatusChange((regdata[1]<<8)|regdata[0]);
			regdata_len = 12;
		
		break;             
		           
//		case SECTION3_ADDR_H20E:
//		break;             
//		case SECTION3_ADDR_H20F:
//		break;
//		case SECTION3_ADDR_H210:
//		break;               
//		case SECTION3_ADDR_H211:
//		break;               
//		case SECTION3_ADDR_H212:
//		break;               
//		case SECTION3_ADDR_H213:
//		break;               
//		case SECTION3_ADDR_H214:
//		break;               
//		case SECTION3_ADDR_H215:
//		break;               
//		case SECTION3_ADDR_H216:
//		break;               
//		case SECTION3_ADDR_H217:
//		break;               
		case SECTION3_ADDR_H218:
#ifdef PBS_FILTER
			if(My_Memcmp(regdata,&g_uNo3RegList[addr-0x200],2)) return 2;
#endif					
			A218_12_14_StatusChange((regdata[1]<<8)|regdata[0]);
			regdata_len = 2;
		
		break;               
		              
		case SECTION3_ADDR_H21A:
#ifdef PBS_FILTER
			if(My_Memcmp(regdata,&g_uNo3RegList[addr-0x200],2)) return 2;
#endif					
			A21A_12_13_StatusChange((regdata[1]<<8)|regdata[0]);
			regdata_len = 2;
		
		break;               
		             
		case SECTION3_ADDR_H21C:
#ifdef PBS_FILTER
			if(My_Memcmp(regdata,&g_uNo3RegList[addr-0x200],2)) return 6;
#endif						
			A21C_255_26_StatusChange((regdata[1]<<8)|regdata[0]);
			regdata_len = 6;
		
		break;               
		              
//		case SECTION3_ADDR_H21E:
//		break;               
//		case SECTION3_ADDR_H21F:
//		break;
//		
//		case SECTION3_ADDR_H220:
//		break;               
//		case SECTION3_ADDR_H221:
//		break;               
		case SECTION3_ADDR_H222:
#ifdef PBS_FILTER
			if(My_Memcmp(regdata,&g_uNo3RegList[addr-0x200],2)) return 2;
#endif						
			A222_255_29_StatusChange((regdata[1]<<8)|regdata[0]);
			regdata_len = 2;
		
		break;               
		              
		case SECTION3_ADDR_H224:
#ifdef PBS_FILTER
			if(My_Memcmp(regdata,&g_uNo3RegList[addr-0x200],2)) return 2;
#endif						
			A224_12_11_StatusChange((regdata[1]<<8)|regdata[0]);
			regdata_len = 2;
		
		break;               
		             
		case SECTION3_ADDR_H226:
#ifdef PBS_FILTER
			if(My_Memcmp(regdata,&g_uNo3RegList[addr-0x200],1)) return 1;
#endif						
			if(Reg.BIT1.bit7)
			{
				A226_12_10_StatusChange(Reg.BIT1.bit0_6);
			}
			regdata_len = 1;
			
		break;               
		case SECTION3_ADDR_H227:
#ifdef PBS_FILTER
			if(My_Memcmp(regdata,&g_uNo3RegList[addr-0x200],2)) return 2;
#endif						
			A227_255_30_StatusChange((regdata[1]<<8)|regdata[0]);
			regdata_len = 2;
		
		break;               
		              
		case SECTION3_ADDR_H229:
	#ifdef PBS_FILTER
			if(My_Memcmp(regdata,&g_uNo3RegList[addr-0x200],2)) return 7;
#endif					
			A229_12_39_StatusChange((regdata[1]<<8)|regdata[0]);
			regdata_len = 7;
		
		break;               
		             
//		case SECTION3_ADDR_H22B:
//		break;               
//		case SECTION3_ADDR_H22C:
//		break;               
//		case SECTION3_ADDR_H22D:
//		break;               
//		case SECTION3_ADDR_H22E:
//		break;               
//		case SECTION3_ADDR_H22F:
//		break;
		
		case SECTION3_ADDR_H230:
#ifdef PBS_FILTER
			if(My_Memcmp(regdata,&g_uNo3RegList[addr-0x200],2)) return 2;
#endif						
			A230_255_32_StatusChange((regdata[1]<<8)|regdata[0]);
			regdata_len = 2;
		
		break;               
		              
		case SECTION3_ADDR_H232:
#ifdef PBS_FILTER
			if(My_Memcmp(regdata,&g_uNo3RegList[addr-0x200],2)) return 9;
#endif						
			A232_12_15_StatusChange((regdata[1]<<8)|regdata[0]);
			regdata_len = 9;
		
		break;               
		             
//		case SECTION3_ADDR_H234:
//		break;               
//		case SECTION3_ADDR_H235:
//		break;               
//		case SECTION3_ADDR_H236:
//		break;               
//		case SECTION3_ADDR_H237:
//		break;               
//		case SECTION3_ADDR_H238:
//		break;               
//		case SECTION3_ADDR_H239:
//		break;               
//		case SECTION3_ADDR_H23A:
//		break;               
		case SECTION3_ADDR_H23B:
#ifdef PBS_FILTER
			if(My_Memcmp(regdata,&g_uNo3RegList[addr-0x200],1)) return 1;
#endif						
			A23B_255_36_StatusChange(Reg.V8);
			regdata_len = 1;
		
		break;               
		case SECTION3_ADDR_H23C:

			addr -=  0x200;
			
			if(Reg.V8 == g_uNo3RegList[addr]) return 1;
		
			A23C_255_37_StatusChange(Reg.V8,g_uNo3RegList[addr]);
		
			g_uNo3RegList[addr] = Reg.V8;						
			
			regdata_len = 2;
		
		break;               
//		case SECTION3_ADDR_H23D:
//			
//		break;                  
		
		default:
		
		break;
	}
	return regdata_len;
}

